<?php
namespace app\admin\model;
use app\common\model\Base;

class TouzhuListOk extends Base
{
    public function lossMemberBetweenInfo($start='',$end='') {
        if($start && $end) {
            $time = array($start,$end);
        } else {
            $time = array('','');
        }
        
        $tz_query = TouzhuListOk::name('touzhu_list_ok')
                            ->field('username,count(id) as num')
                            ->whereTime('tz_time','BETWEEN',$time)
                            ->group('username')
                            ->buildSql();
        $loss_user = TouzhuListOk::name('username')->alias('u')
                            ->join("{$tz_query} tz",'tz.username=u.username','LEFT')
                            ->field('u.username')
                            ->where(['u.swzh'=>0,'u.nbzh'=>0])
                            ->where('tz.num',NULL)
                            ->count();
        return $loss_user;
    }
    
}